package com.g13.virtualpethospital.dto;

import com.g13.virtualpethospital.common.EntityCommon;
import com.g13.virtualpethospital.entity.UserEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Title: SessionData
 * @Author yyj1205
 * @Package com.g13.virtualpethospital.dto
 * @Date 24/3/2024 17:39
 * @description:缓存
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel("SessionData 对话实体")
public class SessionData {
    @ApiModelProperty("用户id")
    String id;
    @ApiModelProperty("用户名称")
    String username;
    @ApiModelProperty("密码")
    String pwd;
    @ApiModelProperty("职能")
    EntityCommon.RoleType role;
    @ApiModelProperty("性别")
    String gender;
    @ApiModelProperty("电话")
    String tel;

    /**
     * 将用户信息转化成缓存数据
     * @param user
     */
    public SessionData(UserEntity user){
        id = user.getId();
        username = user.getUsername();
        pwd = user.getPwd();
        role = user.getRole();
        gender = user.getGender();
        tel = user.getGender();
    }
}
